There has been known a sensor for detecting an object by reception of light from a light projecting unit in a light receiving unit. For example, Japanese Unexamined Patent Publication No. 2013-102424 discloses a photoelectric sensor in which a light receiving unit receives light projected from a light projecting unit, and an object is detected based on whether or not a light reception amount of the light received by the light receiving unit exceeds a previously set threshold. In this photoelectric sensor, an intermediate value between the maximum light reception amount in the case of absence of the object and the minimum light reception amount in the case of presence of the object is set as the threshold.
As the photoelectric sensor disclosed in Japanese Unexamined Patent Publication No. 2013-102424, when the intermediate value between the maximum light reception amount and the minimum light reception amount is set as the threshold while a change in the light reception amount is ignored, a change in the light reception amount in the vicinity of the threshold may be gentle. When such a threshold is set, the photoelectric sensor has a certain degree of extension in the range for decision on detection of the object, and variations might occur in timing for outputting a detection result. Therefore, when machine control, trigger input for an image sensor, or the like is to be performed based on the detection result from the photoelectric sensor, the photoelectric sensor disclosed in Japanese Unexamined Patent Publication No. 2013-102424 has a problem of deviation of the control timing.